package com.erp.myAdapter

import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import com.erp.R
import com.erp.bean.PieceworkGroupingNameBean
import com.erp.bean.ProductionExecuteBean
import com.erp.module.ProductionExecute.ProdutionExecuteContract
import com.erp.module.pieceworkGrouping.PieceworkGroupingContract
import com.erp.util.Myutil
import kotlinx.android.synthetic.main.lv_piecework_grouping_name.view.*

class PieceworkGroupingAdater(private val kv : PieceworkGroupingContract.ProductionGroupingView, private val mlist: List<PieceworkGroupingNameBean>): RecyclerView.Adapter<PieceworkGroupingAdater.ViewHolder>() {

    override fun onCreateViewHolder(parent: ViewGroup, position: Int): ViewHolder {
        val view: View = LayoutInflater.from(parent.context).inflate(R.layout.lv_piecework_grouping_name, parent, false)
        return ViewHolder(view)
    }

    override fun getItemCount(): Int {
        return mlist.size
    }

    override fun onBindViewHolder(h: ViewHolder, position: Int) {
        var bean = mlist[position]
        Log.d("jsongangweidata",bean.toString())
        Myutil.settv(bean.gangwei_name,h.TvGangweiName)
        Myutil.settv(bean.kgg_name,h.TvKggName)
        Myutil.settv(bean.remark,h.TvRemark)
        Myutil.settv(bean.stafflist,h.TvStafflist)
        h.v.setOnClickListener {
            kv.clickGouping(bean)
        }
    }

    class ViewHolder(view: View) : RecyclerView.ViewHolder(view) {
        var TvGangweiName : TextView
        var TvKggName : TextView
        var TvRemark : TextView
        var TvStafflist : TextView
        var v: View
        init {
            v = view
            TvGangweiName = view.TvGangweiName
            TvKggName = view.TvKggName
            TvRemark = view.TvRemark
            TvStafflist = view.TvStafflist
        }
    }
}